#include "UnitTest++/UnitTest++.h"

#include "torus.h"

TEST(Torus)
{
    Coord coord;
    Torus torus;
    torus.lenght = 4;

    CHECK (torus[0][0] == 0);
    CHECK (torus[0][1] == 1);
    CHECK (torus[0][2] == 2);
    CHECK (torus[0][3] == 3);

    CHECK (torus[1][0] == 4);
    CHECK (torus[1][1] == 5);
    CHECK (torus[1][2] == 6);
    CHECK (torus[1][3] == 7);

    CHECK (torus[2][0] == 8);
    CHECK (torus[2][1] == 9);
    CHECK (torus[2][2] == 10);
    CHECK (torus[2][3] == 11);

    CHECK (torus[3][0] == 12);
    CHECK (torus[3][1] == 13);
    CHECK (torus[3][2] == 14);
    CHECK (torus[3][3] == 15);

    torus.coord(torus[0][0],coord);
    CHECK((coord.col ==  0) && (coord.row == 0));
    torus.coord(torus[0][1],coord);
    CHECK((coord.col ==  1) && (coord.row == 0));
    torus.coord(torus[0][2],coord);
    CHECK((coord.col ==  2) && (coord.row == 0));
    torus.coord(torus[0][3],coord);
    CHECK((coord.col ==  3) && (coord.row == 0));

    torus.coord(torus[1][0],coord);
    CHECK((coord.col ==  0) && (coord.row == 1));
    torus.coord(torus[1][1],coord);
    CHECK((coord.col ==  1) && (coord.row == 1));
    torus.coord(torus[1][2],coord);
    CHECK((coord.col ==  2) && (coord.row == 1));
    torus.coord(torus[1][3],coord);
    CHECK((coord.col ==  3) && (coord.row == 1));

    torus.coord(torus[2][0],coord);
    CHECK((coord.col ==  0) && (coord.row == 2));
    torus.coord(torus[2][1],coord);
    CHECK((coord.col ==  1) && (coord.row == 2));
    torus.coord(torus[2][2],coord);
    CHECK((coord.col ==  2) && (coord.row == 2));
    torus.coord(torus[2][3],coord);
    CHECK((coord.col ==  3) && (coord.row == 2));

    torus.coord(torus[3][0],coord);
    CHECK((coord.col ==  0) && (coord.row == 3));
    torus.coord(torus[3][1],coord);
    CHECK((coord.col ==  1) && (coord.row == 3));
    torus.coord(torus[3][2],coord);
    CHECK((coord.col ==  2) && (coord.row == 3));
    torus.coord(torus[3][3],coord);
    CHECK((coord.col ==  3) && (coord.row == 3));

    CHECK (torus.nextCol(0,0) == torus[0][1]);
    CHECK (torus.nextCol(0,1) == torus[0][2]);
    CHECK (torus.nextCol(0,2) == torus[0][3]);
    CHECK (torus.nextCol(0,3) == torus[0][0]);

    CHECK (torus.nextRow(0,1) == torus[1][1]);
    CHECK (torus.nextRow(1,1) == torus[2][1]);
    CHECK (torus.nextRow(2,1) == torus[3][1]);
    CHECK (torus.nextRow(3,1) == torus[0][1]);

    CHECK (torus.previousCol(2,0) == torus[2][3]);
    CHECK (torus.previousCol(2,1) == torus[2][0]);
    CHECK (torus.previousCol(2,2) == torus[2][1]);
    CHECK (torus.previousCol(2,3) == torus[2][2]);

    CHECK (torus.previousRow(0,3) == torus[3][3]);
    CHECK (torus.previousRow(1,3) == torus[0][3]);
    CHECK (torus.previousRow(2,3) == torus[1][3]);
    CHECK (torus.previousRow(3,3) == torus[2][3]);
}

